<?php

//********* 初始化一些目录信息 ****//
    define('ROOT_PATH', dirname(__FILE__) . '/');
    define('LIB_PATH' , ROOT_PATH . 'lib/');
    define('ENGINE_PATH', ROOT_PATH . 'engine/');
    
    //网站域名
    $domain = "yuqing.120open.com";
    
    //任务获取地址
    $dataurl = "http://$domain/index.php?g=Capture&m=data&a=index";
    
    //提交地址
    $posturl = "http://$domain/index.php?g=Capture&m=data&a=postdata";
    
    require LIB_PATH."contents.php";
    require LIB_PATH."function.php";// 导入类库方法
    
    
    $filepath = ROOT_PATH."status.php";
    
    status($filepath);
    
    
    while(file_get_contents($filepath) != "Exit"){
        
        //获取任务
        $task = json_decode(file_get_contents($dataurl),true);
        
        //无任务等待
        if(empty($task)){
            sleep(60);
        }else{
            $keywords = $task['keyword'];  //命中词
            
            $whitelist= str_replace("/","",implode('|',$task['whitelist']));//域名白名单
            
            $brand = $task['brand'];//快照品牌词

            $task  = (array)$task['list'];  //任务
            
            require_once ENGINE_PATH.$task['engine'].".php";       //搜索引擎
            
            $task['engine']($task);
        }
    }
    //退出
    file_put_contents($filepath,"End");
    exit;
